package com.tencent.wxcloudrun.controller;

import com.tencent.wxcloudrun.model.Coupon;
import com.tencent.wxcloudrun.response.R;
import com.tencent.wxcloudrun.service.CouponCateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * ClassName: CouponCateController
 * Package: com.tencent.wxcloudrun.controller
 * Description:
 *
 * @Date: 2023/1/22 8:34 AM
 * @Author: wht
 */
@Slf4j
@RestController
//@RestController = @Controller + @ResponseBody
@RequestMapping("/admin")
public class CouponCateController {
    @Autowired
    CouponCateService couponCateService;

    @PutMapping("/addOneCouponCate")
    public <T> R<T> addOneCouponCate(@RequestBody Coupon coupon) {
        couponCateService.addOneCouponCate(coupon);
        return R.successMsg("添加成功！");
    }

    @PatchMapping("/updateOneCouponCateById")
    public <T> R<T> updateOneCouponCateById(@RequestBody Coupon coupon) {
        couponCateService.updateOneCouponCateById(coupon);
        return R.successMsg("修改成功！");
    }

    @PostMapping("/getCouponCateList")
    public <T> R<T> getCouponCateList(@RequestBody Coupon coupon) {
        List<Coupon> couponList = couponCateService.getCouponCateList(coupon);
        return R.successData(couponList);
    }
}
